package com.itheima;

import java.util.Random;

public class Java_03 {
    public static void main(String[] args) {
        //调用方法
        String rs =create_code(5);
        System.out.println(rs);

    }
    //案例练习：开发验证码
    public static String create_code(int n){
        String code = "";
        Random r= new Random();
        for (int i = 0; i < n; i++) {
            int temp = r.nextInt(3);
            switch (temp){
                case 0:
                    code += r.nextInt(10);
                    break;
                case 1:
                    code +=  (char) (r.nextInt(25)+65);
                    break;
                case 2:
                    code += (char)(r.nextInt(25)+97);
                    break;
            }

        }
        return code;
    }
}
